﻿using Avalonia.Controls;
using LightCAD.Core;
using LightCAD.Runtime;
using LightCAD.UI.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LightCAD.UI
{
    public partial class LineTypeDropDown : DropDownControl
    {
        private List<LcElement> lcElementsList = new List<LcElement>();
        private LcDocument lcDocument;
        private LcLayer selectLayer;
        private LineTypeItemControl linetypeItemControl;
        public LineTypeDropDown()
        {
            InitializeComponent();
            InitializeDropDown(itemsPanel);
        }
        public LineTypeDropDown(LcDocument lcDocument):this()
        {
            this.selectLayer = lcDocument.Layers.First();
            linetypeItemControl = new LineTypeItemControl();
            linetypeItemControl.Location = new Point(0, 2);
            linetypeItemControl.Name = "layerItemControl";
            linetypeItemControl.Size = new Size(155, 24);
            linetypeItemControl.TabIndex = 0;
            linetypeItemControl.ItemClick += LineTypeItemControl_Click;
            this.Controls.Add(linetypeItemControl);
            InitLineType(lcDocument);
        }

        private void LineTypeItemControl_Click(object? sender, string e)
        {
            OpenDropDown();
        }

        public void InitLineType(LcDocument lcDocument)
        {
            this.lcDocument = lcDocument;
            List<LcLineType> linetypes = lcDocument.LineTypes.ToList();
            itemsPanel.Controls.Clear();
            foreach (var linetypeitem in linetypes)
            {
                var linetype = new LineTypeItemControl(linetypeitem);
                linetype.ItemClick += LineTypeItem_ItemClick;
                itemsPanel.Controls.Add(linetype);
            }
            this.Refresh();
        }
        private void LineTypeItem_ItemClick(object? sender, string e) { 
        }
        public void ResetSelectLineType(SelectedEventArgs args)
        {
            
        }
    }
}
